/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.oimwrapper.miscadapters;

import Thor.API.Operations.tcProvisioningOperationsIntf;
import Thor.API.tcResultSet;
import Thor.API.tcUtilityFactory;
import com.thortech.xl.dataaccess.tcDataProvider;

/**
 *
 */
public class AdapterTester {
    
    // userd for testing assignments.
    private String type;
    private String key;

    public AdapterTester() {
        System.out.println("AdapterTester Constructor");
    }

    public void dummyMethod()
    {
        System.out.println("AdapterTester dummyMethod");
    }

    public void printVar(String var)
    {
        System.out.println("AdapterTester printVar " + var);
    }
    
    public void printVar(String varName,String var)
    {
        System.out.println("AdapterTester printVar String " + varName + ":" + var);
    }
    
    public void printVar(long longval)
    {
        System.out.println("AdapterTester printVar long " + longval);
    }
    
    public void printVar(String varName,long longval)
    {
        System.out.println("AdapterTester printVar long " + varName + ":" + longval);
    }
    
    public void printInstanceKey(long instanceKey)
    {
        // print out the orc_key
        System.out.println("AdapterTester printInstanceKey " + instanceKey);
    }

    public void printProcessInstanceDetails(tcDataProvider database,long processInstanceKey)
    {
        System.out.println("Print Process Task Details");
        
        try
        {
            tcProvisioningOperationsIntf provOps = 
                    (tcProvisioningOperationsIntf)tcUtilityFactory.getUtility(database, "Thor.API.Operations.tcProvisioningOperationsIntf");
            tcResultSet rs = provOps.getProcessDetail(processInstanceKey);
            
            String[] headers = null;
            
            if (rs.getRowCount() > 0)
            {
                headers = rs.getColumnNames();
            }
            for(int i=0;i<rs.getRowCount();i++)
            {
                rs.goToRow(i);
                
                for(int c=0;c<headers.length;c++)
                {
                    System.out.println(headers[c] + ":" + rs.getStringValue(headers[c]));
                }
                //System.out.println("Details:" + rs.toString());
                
            }
        }
        catch(Exception e)
        {
            System.out.println("Error Marking Task Complete");
            e.printStackTrace();
        }
    }
    
    // used to test assignment tasks.
    
    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }
    
    


}
